
package edu.ccut.saturn.studio.wfg.part;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;

import edu.ccut.saturn.studio.wfg.command.ShapeDeleteCommand;
import edu.ccut.saturn.studio.wfg.model.Shape;
import edu.ccut.saturn.studio.wfg.model.ShapesDiagram;

class ShapeComponentEditPolicy extends ComponentEditPolicy {

	protected Command createDeleteCommand(GroupRequest deleteRequest) {
		Object parent = getHost().getParent().getModel();
		Object child = getHost().getModel();
		if (parent instanceof ShapesDiagram && child instanceof Shape) {
			return new ShapeDeleteCommand((ShapesDiagram) parent, (Shape) child);
		}
		return super.createDeleteCommand(deleteRequest);
	}
}